<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9">
    <title>Multiple y-axes with valueRange</title>
    <!--[if IE]>
    <script type="text/javascript" src="../excanvas.js"></script>
    <![endif]-->
    <!--
    For production (minified) code, use:
    <script type="text/javascript" src="dygraph-combined.js"></script>
    -->
    <script type="text/javascript" src="../dygraph-dev.js"></script>

  </head>
  <body>
    <h2>Multiple y-axes with valueRange</h2>
    <p>The same data with both different valueRanges. Two-axis old y[40, 70] valueRange:</p>
    <div id="demodiv" style="width: 640; height: 350; border: 1px solid black"></div>
    <p>Two-axis new valueRange y[40, 80] set:</p>
    <div id="demodiv_one" style="width: 640; height: 350; border: 1px solid black"></div>
    <p>Two-axis new valueRange y[40, 80] &amp; y2[1e6, 1.2e6] set:</p>
    <div id="demodiv_two" style="width: 640; height: 350; border: 1px solid black"></div>
    <script type="text/javascript">
      var data = [];
      for (var i = 1; i <= 100; i++) {
        var m = "01", d = i;
        if (d > 31) { m = "02"; d -= 31; }
        if (m == "02" && d > 28) { m = "03"; d -= 28; }
        if (m == "03" && d > 31) { m = "04"; d -= 31; }
        if (d < 10) d = "0" + d;
        // two series, one with range 1-100, one with range 1-2M
        data.push([new Date("2010/" + m + "/" + d),
                   i,
                   100 - i,
                   1e6 * (1 + i * (100 - i) / (50 * 50)),
                   1e6 * (2 - i * (100 - i) / (50 * 50))]);
      }

      g = new Dygraph(
          document.getElementById("demodiv"),
          data,
          {
            labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
            series : {
              'Y3': {
                axis: {
                }
              },
              'Y4': {
                axis: 'Y3'  // use the same y-axis as series Y3
              }
            },
            valueRange: [40, 70],
            axes: {
              y2: {
                // set axis-related properties here
                labelsKMB: true
              }
            },
            ylabel: 'Primary y-axis',
            y2label: 'Secondary y-axis',
            yAxisLabelWidth: 60
          }
      );

      g2 = new Dygraph(
          document.getElementById("demodiv_one"),
          data,
          {
            labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
            series : {
              'Y3': {
                axis: {
                }
              },
              'Y4': {
                axis: 'Y3'  // use the same y-axis as series Y3
              }
            },
            axes: {
              y: {
                valueRange: [40, 80]
              },
              y2: {
                // set axis-related properties here
                labelsKMB: true
              }
            },
            ylabel: 'Primary y-axis',
            y2label: 'Secondary y-axis',
            yAxisLabelWidth: 60
          }
      );

      g2 = new Dygraph(
          document.getElementById("demodiv_two"),
          data,
          {
            labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
            series : {
              'Y3': {
                axis: {
                }
              },
              'Y4': {
                axis: 'Y3'  // use the same y-axis as series Y3
              }
            },
            axes: {
              y: {
                valueRange: [40, 80]
              },
              y2: {
                // set axis-related properties here
                valueRange: [1e6, 1.2e6],
                labelsKMB: true
              }
            },
            ylabel: 'Primary y-axis',
            y2label: 'Secondary y-axis',
            yAxisLabelWidth: 60
          }
      );


    </script>
</body>
</html>
